package com.woniu.util;

import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Classname TopicPublisher
 * @Description TODO
 * @Date 2025/10/24 16:02
 * @Created by pc
 */
@Component
public class TopicPublisher implements RabbitTemplate.ReturnsCallback, RabbitTemplate.ConfirmCallback {
    @Resource
    private RabbitTemplate rabbitTemplate;

    public void send(String code,String routingKey){
        rabbitTemplate.setConfirmCallback(this);
        rabbitTemplate.setReturnsCallback(this);
        rabbitTemplate.convertAndSend("topicExchange",routingKey,code);
    }

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {

    }

    @Override
    public void returnedMessage(ReturnedMessage returned) {

    }
}
